# 深拷贝和浅拷贝
## 浅拷贝
list1 = [1, 2, 3]
list2 = list(list1)
print(list2)
print("list1 == list2 ?", list1 == list2)
print("list1 is list2 ?", list1 is list2)
print()

set1 = set([1, 2, 3])
set2 = set(set1)
print(set2)
print("set1 == set2 ?", set1 == set2)
print("set1 is set2 ?", set1 is set2)
print()

list1 = [1, 2, 3]
list2 = list1[:]
print(list2)
print("list1 == list2 ?", list1 == list2)
print("list1 is list2 ?", list1 is list2)
print()

import copy
list1 = [1, 2, 3]
list2 = copy.copy(list1)
print(list2)
print("list1 == list2 ?", list1 == list2)
print("list1 is list2 ?", list1 is list2)
print()

tuple1 = (1, 2, 3)
tuple2 = tuple(tuple1)
print(tuple2)
print("tuple1 == tuple2 ?", tuple1 == tuple2)
print("tuple1 is tuple2 ?", tuple1 is tuple2)
print()

list1 = [[1, 2], (30, 40)]
list2 = list(list1)

list1.append(100)
print("list1 =", list1)
print("list2 =", list2)

list1[0].append(3)
print("list1 =", list1)
print("list2 =", list2)

list1[1] += (50, 60)
print("list1 =", list1)
print("list2 =", list2)
print()

## 深拷贝
list1 = [[1, 2], (30, 40)]
list2 = copy.deepcopy(list1)

list1.append(100)
print("list1 =", list1)
print("list2 =", list2)

list1[0].append(3)
print("list1 =", list1)
print("list2 =", list2)

list1[1] += (50, 60)
print("list1 =", list1)
print("list2 =", list2)

